'''
# 作者    ： 张莹潇
# 创建时间 ： 20/12/8 10:14
'''
from event import EventEngine
from trader.engine import MainEngine
from trader.ui import MainWindow, create_qapp
from gateway.ctp import CtpGateway
from app.cta_strategy import CtaStrategyApp
from app.cta_backtester import CtaBacktesterApp
from app.data_manager import DataManagerApp
from app.portfolio_strategy import PortfolioStrategyApp


def main():
    """Start VN Trader"""
    qapp = create_qapp()

    event_engine = EventEngine()
    main_engine = MainEngine(event_engine)

    main_engine.add_gateway(CtpGateway)
    main_engine.add_app(CtaStrategyApp)
    main_engine.add_app(CtaBacktesterApp)
    main_engine.add_app(DataManagerApp)
    main_engine.add_app(PortfolioStrategyApp)

    main_window = MainWindow(main_engine, event_engine)
    main_window.showMaximized()

    qapp.exec()


if __name__ == "__main__":
    main()